extension OptionalStringExtension on String? {

  bool get isEmptyOrNull => this == null || this!.isEmpty;
  bool get isNotEmptyOrNull => this != null && this!.isNotEmpty;
  String get orEmpty => this ?? '';

  /// 是否为Email
  bool get isEmail => isNotEmptyOrNull && this!.isEmail;
}

extension StringExtension on String {
  /// 移除0x00字节码
  String delNul() {
    return replaceAll('\x00', '');
  }

  int get versionNum{
   final versionStr = replaceAll(RegExp(r'[^0-9.]'), '');
   final list = versionStr.split('.');
    if (list.length == 3) {
      return int.parse(list[0]) * 10000 + int.parse(list[1]) * 100 + int.parse(list[2]);
    } else if (list.length == 2) {
      return int.parse(list[0]) * 10000 + int.parse(list[1]) * 100;
    } else if (list.length == 1) {
      return int.parse(list[0]) * 10000;
    } else {
      return 0;
    }
  }

  //对比版本号
  int compareVersion(String version) {
    return versionNum.compareTo(version.versionNum);
  }
}